package com.example.demo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.nio.charset.StandardCharsets;

@RestController
public class TestController {

    @Value("${com.test.name}")
    private String name;

    private String want;

    @Value("${com.test.bbb}")
    private String bbb;

    @Autowired
    private ConfigBean configBean;

    @Autowired
    private ConfigTestBean configTestBean;

    @RequestMapping(value = "/test1")
    public String test1() {
        return name + want;
    }

    @RequestMapping(value = "/test2")
    public String test2(){
        return bbb;
    }

    @RequestMapping(value = "/test3")
    public String test3() {
        return configBean.getBbb();
    }

    @RequestMapping(value = "/test4")
    public String test4() {
        return configTestBean.getBbb();
    }

    public String getWant() {
        return want;
    }

    @Autowired
    public void setWant(@Value("${com.test.want}")String want) {
        //this.want = new String(want.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
        this.want = want;
    }
}
